package com.longqin.wechat.listener;

import javax.annotation.Resource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.event.EventListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

import com.longqin.wechat.entity.Log;
import com.longqin.wechat.mapper.LogMapper;

/**异步日志监听类
 *
 */
@Component
public class SysLogListener {
	
	public static final Logger log = LoggerFactory.getLogger(SysLogListener.class);
	 
	@Resource
	private LogMapper logMapper;
	
	/**异步插入系统日志
	 * @param event
	 * @throws Exception 
	 */
	@Async
	@EventListener(SysLogEvent.class)
	public void saveSysLog(SysLogEvent event) throws Exception {
		Log log = (Log)event.getSource();
		logMapper.insert(log);
	}

}
